package com.wingbow.ticket.util;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Md5Util {
    /**
     * md5签名
     * 
     * @param md5
     * @return
     */
    public static String MD5(String md5) {
        String res = "";
        try {
            java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
            byte[] array = md.digest(md5.getBytes("utf-8"));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < array.length; ++i) {
                sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
            }
            res = sb.toString();
        } catch (Exception e) {
            log.error("md5签名错误", e);
        }

        return res;
    }
}
